package com.kklsqm.langchain4j.controller;

import com.kklsqm.langchain4j.service.ImageEraseCompletionService;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;


/**
 * 功能: 图片擦除
 * 作者: 沙琪马
 * 日期: 2025/5/9 16:59
 */
@RestController
@RequestMapping("/image")
public class ImageEraseController {

    @Resource
    private ImageEraseCompletionService eraseService;

    @PostMapping("/erase")
    public ResponseEntity<String> eraseImage(@RequestParam String imageUrl,
                                             @RequestParam String maskUrl,
                                             @RequestParam String foregroundUrl) throws IOException {

        String resultUrl = eraseService.eraseImage(imageUrl, maskUrl, foregroundUrl);
        return ResponseEntity.ok(resultUrl);
    }
}
